﻿using SqlSugar;
using Zhp.Common.Appsetting;

namespace Zhp.Common.Helper
{
    public static class SnowFlakeHelper
    {
        /// <summary>
        /// 唯一key
        /// </summary>
        /// <returns></returns>
        public static long GetLongId() => SnowFlakeSingle.Instance.NextId();

        /// <summary>
        /// 程序启时动执行一次就行
        /// </summary>
        /// <param name="WorkId"></param>
        /// <returns></returns>
        public static void SetWorkId()
        {
            var options = AppSettingHelper.GetOptions<SysDataOptions>();
            SnowFlakeSingle.WorkId = options.WorkId;
        }
    }
}
